<script setup>
import {ref,defineEmits,defineProps,watch} from "vue";
// import selectperson from  "@/views/material/workshop/selectperson.vue";
import request  from '@/api/request'
import { useRouter } from "vue-router"
let router = useRouter();
let emits=defineEmits(["ref-table"])
let props = defineProps({
    data: {
        type: Object,
        default: () => ({})
    }
})
let data = ref()

let Process=ref([]);
let  select=()=>{
        request({
        url:'/processStep/Name',
        method:'get'
    }).then(res=>{
        Process.value=res.data
        
    })

}
select()
let Workshop=ref([]);
let  select1=()=>{
        request({
        url:'/workstation/Name',
        method:'get'
    }).then(res=>{
        Workshop.value=res.data
        
    })

}
select1()

let onSubmit=()=>{
     request({
        url: '/workstation/update',
        method: 'put',
        data: {
            ...workstation.value,
                
        }
    }).then(res => {
        emits("ref-table")
    })
       
}


let workshop=ref({})





let title = ref("");
let isVisible = ref(false);
let refTanle1 = (a) => {
  isVisible.value = false;
  workshop.value.person= a.value.nickname
};

let workstation = ref({
    ...props.data
  
})
</script>
<template>
    <div>
        <el-card>
            <template #header>
                <el-form :model="workstation" ref="form"  style="padding-left: 70px;" :inline="false"  class="card_wrap">
                    <el-form-item label="工作站编号" class="c_item_big">
                        <el-input v-model="workstation.workstationId" style="width: 350px;" disabled ></el-input>
                    </el-form-item>
                    <el-form-item label="工作站名称" class="c_item_big">
                        <el-input v-model="workstation.workstationName" style="width: 350px;" ></el-input>
                    </el-form-item>
                    <el-form-item label="工作站地点" class="c_item_big">
                        <el-input v-model="workstation.workstationLocation" style="width: 350px;" ></el-input>
                    </el-form-item>
                      <el-form-item label="所在车间名称" size="default" prop="workshopId" class="c_item_big">
                                    <el-select placeholder="请选择车间" 
                                 v-model="workstation.workshopId" 
                                    style="width: 150px;"
                                >
                                    <el-option 
                                    v-for="intm in Workshop" 
                                    :value="intm.workshopcId" 
                                    :label="intm.workshopName"
                                    ></el-option>

                                </el-select>
                                </el-form-item>

                                <el-form-item label="所属工序"  class="c_item">
                                    <el-select placeholder="请选择工序" 
                                 v-model="workstation.processId" 
                                    style="width: 150px;"
                                >
                                    <el-option 
                                    v-for="intm in Process" 
                                    :value="intm.processId" 
                                    :label="intm.processName"
                                    ></el-option>

                                </el-select>
                                </el-form-item>
                    
                   
                    <el-form-item  label="是否启用" class="c_item">
                                <el-radio-group v-model="workstation.isEnabled" @change="">
                                    <el-radio label="是" :value="0">是</el-radio>
                                    <el-radio label="否" :value="1">否</el-radio>
                                </el-radio-group>
                    </el-form-item>

                   <el-form-item label="备注" class="c_item_big">
                        <el-input v-model="workstation.remark" style="width: 350px;" ></el-input>
                    </el-form-item>

                   

                    
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit" class="right-bottom">修改</el-button>
                    </el-form-item>
               
                </el-form>
            </template>
        </el-card>
    
   
        <router-view/>
    </div>
</template>
<style scoped>
.c_item {
    flex: 1;
    margin: 0px 5px 15px 0;
    width: calc((100%-10px)/2);
    min-width: calc((100% - 10px)/2);
    max-width: calc((100% - 10px)/2);

    &:nth-child(3n) {
        margin-right: 0;
    }
}
.c_item_big {
    flex: 2;
    margin: 0px 5px 15px 0;
    width: calc((100%-10px)/1);
    min-width: calc((100% - 10px)/1);
    max-width: calc((100% - 10px)/1);

    &:nth-child(3n) {
        margin-right: 0;
    }
}
.card_wrap {
    width: 98%;
    
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.color {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.right-bottom{
 margin-top: 10px;
 margin-left: 700px ;
}
.right-bottom2{
 margin-top: 20px;
 margin-left: 850px ;
}
</style>